/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;

/**
 *
 * @author My PC
 */
public class frmMain extends javax.swing.JFrame {

    /**
     * Creates new form frmMain
     */
    private boolean isAdmin = false;

    public frmMain() {
    }

    public frmMain(String user) {
        initComponents();
        initTabPanel();
        lblUserName.setText(user);
    }

    public frmMain(boolean isAdmin, String user) {
        this.isAdmin = true;
        initComponents();
        initTabPanel();
        lblUserName.setText(user);
    }

    private void initTabPanel() {
        //
        PanelRoom pnr = new PanelRoom();
        tbnPanel.addTab("ROOM", pnr);

        PanelSubject pns = new PanelSubject();
        tbnPanel.addTab("SUBJECT", pns);

        PanelTimeTable pntt = new PanelTimeTable();
        tbnPanel.addTab("TIME TABLE", pntt);

        if (isAdmin) {
            PanelUser pnu = new PanelUser();
            tbnPanel.addTab("USERS", pnu);
        }

        PanelDevice pnd = new PanelDevice();
        tbnPanel.addTab("DEVICES", pnd);

        PanelDeviceInRoom pndir = new PanelDeviceInRoom();
        tbnPanel.add("DEVICES IN ROOM", pndir);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        pnlBanner = new javax.swing.JPanel();
        lblBannerImg = new javax.swing.JLabel();
        lblUserName = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tbnPanel = new javax.swing.JTabbedPane();
        menuMain = new javax.swing.JMenuBar();
        menuSystem = new javax.swing.JMenu();
        menuILogout = new javax.swing.JMenuItem();
        menuIExit = new javax.swing.JMenuItem();
        menuHelp = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setPreferredSize(new java.awt.Dimension(2147483647, 2147483647));

        pnlBanner.setBackground(new java.awt.Color(255, 255, 255));
        pnlBanner.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        lblBannerImg.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Fotor01021103644.png"))); // NOI18N
        pnlBanner.add(lblBannerImg, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

        lblUserName.setFont(new java.awt.Font("Times New Roman", 2, 24)); // NOI18N
        lblUserName.setForeground(java.awt.Color.blue);
        lblUserName.setText("user");
        pnlBanner.add(lblUserName, new org.netbeans.lib.awtextra.AbsoluteConstraints(1130, 60, -1, -1));

        jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        jLabel1.setText("Hello");
        pnlBanner.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(1070, 60, -1, -1));

        jScrollPane1.setViewportView(tbnPanel);

        menuSystem.setText("System");

        menuILogout.setText("Logout");
        menuILogout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuILogoutActionPerformed(evt);
            }
        });
        menuSystem.add(menuILogout);

        menuIExit.setText("Exit");
        menuIExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuIExitActionPerformed(evt);
            }
        });
        menuSystem.add(menuIExit);

        menuMain.add(menuSystem);

        menuHelp.setText("Help");
        menuMain.add(menuHelp);

        setJMenuBar(menuMain);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(pnlBanner, javax.swing.GroupLayout.DEFAULT_SIZE, 1265, Short.MAX_VALUE)
            .addComponent(jScrollPane1)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(pnlBanner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 357, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void menuIExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuIExitActionPerformed
        System.exit(0);
    }//GEN-LAST:event_menuIExitActionPerformed

    private void menuILogoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuILogoutActionPerformed
        this.dispose();
        frmLogin login = new frmLogin();
        login.setVisible(true);
    }//GEN-LAST:event_menuILogoutActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */

        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new frmMain().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JLabel lblBannerImg;
    private javax.swing.JLabel lblUserName;
    private javax.swing.JMenu menuHelp;
    private javax.swing.JMenuItem menuIExit;
    private javax.swing.JMenuItem menuILogout;
    private javax.swing.JMenuBar menuMain;
    private javax.swing.JMenu menuSystem;
    private javax.swing.JPanel pnlBanner;
    private javax.swing.JTabbedPane tbnPanel;
    // End of variables declaration//GEN-END:variables
}
